package com.purchase.ml.mapper.dealer;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.purchase.ml.entity.dealer.SysDealerCategory;
import com.purchase.ml.entity.dealer.SysDealerPruduct;
import com.purchase.ml.entity.prod.SysCategory;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author :zxm
 * @date :2021/3/11 17:11
 * @description :some description
 **/
@Mapper
@Repository
public interface DealerCategoryMapper  extends BaseMapper<SysDealerCategory> {

    /**
     * 主经销商/经销商购买商品成功后，保存其商品分类信息
     * @param category
     * @return
     */
    @Insert("insert into sys_dealer_category(`category_id`,`state`,`dealer_id`,`index`) values(#{category.categoryId} ,#{category.state} ,#{category.dealerId},#{category.index} );")
    int addDealerCategory(@Param("category") SysDealerCategory category);

    /**
     * 通过经销商id查询经销商目录分类
     * @param buyer
     * @return
     */
    @Select("select * from sys_dealer_category where dealer_id=#{dealerId} and category_id=#{categoryId}  ")
    SysDealerCategory findBuyerCategoryByDealerId(@Param("dealerId") Long buyer,@Param("categoryId") Long categoryId);

    /**
     * 通过分类id查找商品分类
     * @param categoryId
     * @return
     */
    @Select("select * from sys_dealer_category where category_id=#{categoryId} and dealer_id=#{dealerId} ")
    SysCategory findByCategoryId(@Param("categoryId") Long categoryId,@Param("dealerId")Long dealerId);

}
